﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.IO;

public partial class Controls_ucSupport : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            loadSupport();
        }

    }

    private DataSet createObjDS()
    {
        DataSet objDS = new DataSet("Supports");
        string path = Server.MapPath("../upload/xml/Support.xml");
        if (File.Exists(path))
        {
            objDS.ReadXml(path);
            if (objDS == null || objDS.Tables.Count <= 0)
                objDS.Tables.Add(createObjDT());
        }
        else
            objDS.Tables.Add(createObjDT());
        return objDS;
    }
    private DataTable createObjDT()
    {
        DataTable objDT = new DataTable("Support");
        objDT.Columns.Add("NAME", typeof(String));
        objDT.Columns.Add("YAHOO", typeof(String));
        objDT.Columns.Add("PHONE", typeof(String));
        return objDT;
    }
    private void loadSupport()
    {
        try
        {
            DataSet objDS = createObjDS();
            if (Request["index"] != null)
            {
                //txtName.Text = objDS.Tables[0].Rows[Convert.ToInt32(Request["index"]) - 1]["NAME"].ToString();
                //txtYahoo.Text = objDS.Tables[0].Rows[Convert.ToInt32(Request["index"]) - 1]["YAHOO"].ToString();
            }
            DataTable objDT = objDS.Tables[0];
            rptSupport.DataSource = objDS;
            rptSupport.DataBind();
        }
        catch (Exception ex)
        {

        }
    }
}